package cn.usian.pricingstrategy.coefficient.controller;

import cn.usian.pojo.Result;
import cn.usian.pojo.pricingstrategy.coefficient.PricingSpecialCoefficient;
import cn.usian.pricingstrategy.coefficient.service.ICoefficientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/coefficient")
public class CoefficientController {
    @Autowired
    private ICoefficientService coefficientService;

    @GetMapping("/list")
    public Result list(){
        return Result.ok(coefficientService.list());
    }

    @PostMapping("/save")
    public Result save(@RequestBody PricingSpecialCoefficient pricingSpecialCoefficient){
        coefficientService.save(pricingSpecialCoefficient);
        return Result.ok();
    }

    @PostMapping("/update")
    public Result update(@RequestBody PricingSpecialCoefficient pricingSpecialCoefficient){
        coefficientService.update(pricingSpecialCoefficient);
        return Result.ok();
    }

    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable("id") Long id){
        return Result.ok(coefficientService.findById(id));
    }

}
